package com.atguigu.gmall.product.api;

import com.atguigu.gmall.model.product.*;
import com.atguigu.gmall.product.service.ManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * @author Administrator
 * @create 2020-05-15 18:37
 */
@RequestMapping("/api/product/inner")
@RestController
public class ProductApiController {

    @Autowired
    private ManageService manageService;

    // 根据skuId获取sku信息
    @GetMapping("/getSkuInfo/{skuId}")
   public SkuInfo getSkuInfo(@PathVariable("skuId") Long skuId){
        //return manageService.getSkuInfoAop(skuId);
       return manageService.getSkuInfo(skuId);
    };

    //通过三级分类id查询分类信息
    @GetMapping("/getCategoryView/{category3Id}")
    public BaseCategoryView getCategoryView(@PathVariable("category3Id") Long category3Id){
        return manageService.getCategoryViewAop(category3Id);
    };

   //获取sku最新价格
    @GetMapping("/getSkuPrice/{skuId}")
    public BigDecimal getSkuPrice(@PathVariable(value = "skuId") Long skuId){
        return manageService.getSkuPrice(skuId);
    };

    //根据spuId，skuId 查询销售属性集合
    @GetMapping("/getSpuSaleAttrListCheckBySku/{skuId}/{spuId}")
    List<SpuSaleAttr> getSpuSaleAttrListCheckBySku(@PathVariable(name = "skuId") Long skuId,
                                                   @PathVariable(name = "spuId") Long spuId){
        return manageService.getSpuSaleAttrListCheckBySku(skuId,spuId);
    };

    //根据spuId 查询map 集合属性
    @GetMapping("/getSkuValueIdsMap/{spuId}")
    Map getSkuValueIdsMap(@PathVariable("spuId") Long spuId){
        return manageService.getSkuValueIdsMap(spuId);
    };


    //首页查询一二三级数据 生成静态化页面
    @GetMapping("/getBaseCategoryMap")
    public List<Map> getBaseCategoryMap(){
        return manageService.getBaseCategoryMap();
    }

    //根据品牌id查询品牌信息
    @GetMapping("/getBaseTrademark")
    public BaseTrademark getBaseTrademark(@PathVariable(name ="tmId")Long tmId){
        BaseTrademark baseTrademark =manageService.getBaseTrademark(tmId);
        return baseTrademark;
    };

    //根据SkuId查询平台属性id/名称 平台属性值的名称
    @GetMapping("/getAttrList/{skuId}")
    public List<SkuAttrValue> getAttrList(@PathVariable(name = "skuId") Long skuId){
       return manageService.getAttrList(skuId);
    };

}
